<template>
	<view class="mydpj">
		<view class="main-pd">
			<view class="star-block">
					<view class="color-595959 font-28 u-m-b-38">满意度评价</view>
					<view class="u-flex u-flex-center">
						<u-rate :count="count" v-model="value"
						:size="40" :readonly="bxMsg.isPj == 1"
						 active-color="#faad14"></u-rate>
					</view>
			</view>
			<view class="u-m-t-114" v-if="bxMsg.isPj == 0">
				<u-button text="提交" shape="circle"
				color="linear-gradient(90deg, #FA827D 0%, #F34B47 100%)"
				:customStyle="{
					fontSize:'36rpx',
					height:'96rpx'
				}" @click="submitPj"
				></u-button>
			</view>
		</view>
	</view>
</template>

<script setup>
import { ref } from "vue"
import { BxPjApi, getBxInfoApi } from "@/api/index"
import { onLoad } from "@dcloudio/uni-app"
let count = ref(5)
let value = ref(0)
let id = ref('')
let bxMsg = ref({});
const getBxInfoHandle = (id) => {
	getBxInfoApi({
		id,
	}).then((res) => {
		if (res.success) {
			bxMsg.value = res.data;
			value.value = res.data.pjNumber
		}
	});
};
// 打分
const submitPj = () => {
	if (value.value == 0) {
		uni.$u.toast("请打分！");
		return false;
	}
	BxPjApi({ id: id.value, pjNumber: value.value }).then(res => {
		if (res.success) {
			uni.$u.toast("评价成功");
			setTimeout(() => {
				uni.navigateBack()
			}, 1500)
		} else {
			uni.$u.toast(res.msg)
		}
	})
}
onLoad((param) => {
	id.value = param.id
	getBxInfoHandle(param.id)
})
</script>

<style lang="scss" scoped>
.mydpj{
	padding-top: 28rpx;
.star-block{
	background-color: #fff;
	border-radius: 12rpx;
	padding: 28rpx 32rpx 59rpx;
	box-sizing: border-box;
}
}
</style>
